package fr.flambycrew.util;

import java.net.URL;

import org.apache.commons.lang3.StringUtils;

public abstract class FileUtil {

	private static final String FILE_SEPARATOR = "\\";
	private static final String EXTENSION_HTML = ".html";
	private static final char URL_SPLITTER = '/';

	public static String getExportedFilePath(URL url, String targetDirectoryPath) {
		return targetDirectoryPath + FILE_SEPARATOR + getUrlRelevantPart(url.toString()) + EXTENSION_HTML;
	}

	private static String getUrlRelevantPart(String url) {
		return StringUtils.isNotEmpty(url) ? url.substring(url.lastIndexOf(URL_SPLITTER) + 1) : null;
	}

}
